/*package com.wooophone.mpyeah.test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;

import com.wooophone.common.util.JsonSfUtil;
import com.wooophone.mpyeah.biz.BrandCategoryBiz;
import com.wooophone.mpyeah.biz.exception.CannotDeleteException;
import com.wooophone.mpyeah.entity.BrandCategory;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

@ContextConfiguration(locations = { "/spring/applicationContext*.xml" })
public class BrandCategoryBizTestCase extends AbstractJUnit4SpringContextTests {
	@Autowired
	BrandCategoryBiz brandCategoryBiz;
	
	@Test
	public void test1(){
		BrandCategory brandCategory = brandCategoryBiz.get("055353ab18de11e1aeb634d58f4cce24");
		
		System.out.println(brandCategory.getName());
		System.out.println(brandCategory.getBrands());
		System.out.println(brandCategory.getParent());
		System.out.println(brandCategory.getGradeFieldList());
	}
	
	@Test public void test(){
		System.out.println(brandCategoryBiz);
		
		BrandCategory brandCategory=new BrandCategory();
		brandCategory.setName("上衣/外套");
		brandCategory.setCreator("minglic");
		brandCategory.setEditor("minglic_edit");
		brandCategory.setIcon("http://img3.bbs.szhome.com/UploadFiles/Images/2009/03/29/29155607312.jpg");
		brandCategory.setGradeField("['材质','售后服务','服务态度','品质']");
		brandCategory.setMore("更多信息");
		brandCategory.setDescription("描述信息");
		brandCategory.setStatus(1);
		brandCategory.setParentId("23456789");
		
		brandCategoryBiz.save(brandCategory);
		//如果ID不为空，说明保存成功
		assertThat(brandCategory.getId()!=null, is(true));
		System.out.println("保存成功："+brandCategory.getId());
		
		BrandCategory brandCategory2=new BrandCategory();
		brandCategory2.setName("保暖类型");
		brandCategory2.setCreator("minglic");
		brandCategory2.setEditor("minglic_edit");
		brandCategory2.setIcon("http://img3.bbs.szhome.com/UploadFiles/Images/2009/03/29/29155607312.jpg");
		brandCategory2.setGradeField("['材质','售后服务','服务态度','品质']");
		brandCategory2.setMore("更多信息");
		brandCategory2.setDescription("描述信息");
		brandCategory2.setStatus(1);
		brandCategory2.setParent(brandCategory);
		
		brandCategoryBiz.save(brandCategory2);
				
		//如果ID不为空，说明保存成功
		assertThat(brandCategory2.getId()!=null, is(true));
		System.out.println("保存成功："+brandCategory2.getId());

		System.out.println("录入的第一条数据：");
		System.out.println(JsonSfUtil.toJsonByJsonLib(brandCategory));
		System.out.println("录入的第二条数据：");
		System.out.println(JsonSfUtil.toJsonByJsonLib(brandCategory2));
		
		BrandCategory brandCategoryNew1=new BrandCategory();
		brandCategoryNew1=brandCategoryBiz.get(brandCategory.getId());
		System.out.println("取出的第一条数据：");
		System.out.println(brandCategoryNew1.getId());
		assertThat(brandCategoryNew1.getId(), is(brandCategory.getId()));

		BrandCategory brandCategoryNew2=new BrandCategory();
		brandCategoryNew2=brandCategoryBiz.get(brandCategory2.getId());
		System.out.println("取出的第二条数据：");
		System.out.println(brandCategoryNew2.getId());
		assertThat(brandCategoryNew2.getId(), is(brandCategory2.getId()));
		
		List<BrandCategory> children = brandCategoryNew1.getChildren();
		for (BrandCategory brandCategory3 : children) {
			System.out.println("取出的第一条分类的子级分类：");
//			JsonSfUtil.toJsonByJsonLib(brandCategory3);
			System.out.println(brandCategory3.getId());
			assertThat(brandCategoryNew1.getChildren().get(0).getId(), is(brandCategory2.getId()));
		}
		
		System.out.println("第二条分类的子级分类：");
		System.out.println(brandCategoryNew2.getParent().getId());
		assertThat(brandCategoryNew2.getParent().getId(), is(brandCategory.getId()));
		
		List<BrandCategory> list=brandCategoryBiz.list();
		int count=brandCategoryBiz.count();
		
		System.out.println("list 与 count 方法测试");
		assertThat(count, is(list.size()));
		
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("id", brandCategory.getId());
		List<BrandCategory> listFind = brandCategoryBiz.find(parameter);
		assertThat(1, is(listFind.size()));
		assertThat(brandCategory.getId(), is(listFind.get(0).getId()));
		
		int deleteCount=0;
		System.out.println("有子级时第一次尝试删除");
		try {
			deleteCount = brandCategoryBiz.delete(brandCategory.getId());
			fail("未抛出异常");
		} catch (CannotDeleteException e) {
			e.printStackTrace();
			assertTrue(true);
		}
		
		try {
			deleteCount = brandCategoryBiz.delete(brandCategory2.getId());
		} catch (CannotDeleteException e) {
			e.printStackTrace();
			fail("抛出异常");
		}
		System.out.println("成功删除"+deleteCount+"条记录");
		

		System.out.println("有子级时第二次尝试删除");
		try {
			deleteCount = brandCategoryBiz.delete(brandCategory.getId());
		} catch (CannotDeleteException e) {
			e.printStackTrace();
			fail("抛出异常");
		}
		System.out.println("成功删除"+deleteCount+"条记录");
	}
	
	
	
	@Test
	public void updateTest(){
		BrandCategory brandCategory=brandCategoryBiz.get("4e2cbfb618de11e1aeb634d58f4cce24");
		brandCategoryBiz.update(brandCategory);
		
	}
}
*/